package com.sy.blog.vo;

import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * 返回给前端的数据格式
 */
@Data
@AllArgsConstructor  // 所有参数构造方法
public class Result {

    private Boolean success;

    private Integer code;

    private String msg;

    /**
     * 注意要用object类型来表示返回的具体数据
     */
    private Object data;

    public static Result success(Object data) {
        return new Result(true, 200, "success", data);
    }

    public static Result fail(int code, String mag) {
        return new Result(false, code, mag, null);
    }
}
